package com.csg.ses.common.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @auther wangjun
 * @date 2020/11/16
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * 构建DocketBean
     * @return
     */
    @Bean
    public Docket buildDocketBean() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(initApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.csg.ses.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo initApiInfo() {
        return new ApiInfoBuilder()
                .title("Restful Api of Smart Electricity Service System")
                .description("智能电费服务系统restful api接口文档")
                .version("1.0")
                .build();
    }
}